﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entidades;
using UVM_Pretira_BL;
using UVM_Utileria;

public partial class UVMPRETIRA : System.Web.UI.Page
{
    private Usuario usr = null;
    private PretiraBL bl = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
           
            if (Session["Usuario"] != null)
            {
                if (bl == null)
                {
                    bl = new PretiraBL();
                }
                usr = Session["Usuario"] as Usuario;
                lblmatricula.InnerText = usr.UserName;
                lblnombre.InnerText = usr.Nombre;
                lblplan.InnerText = usr.PLAN;
                lblcarrera.InnerText = usr.Email;

                List<Oferta> lstoferta = bl.GetOferta(usr);
                ListItem itec = null;
                string horario = string.Empty;
                
                foreach (var item in lstoferta)
                {
                    string cursadd = string.Empty;
                    if ("1" == Utilerias.GetValueAppConfig("confCurso"))
                    {
                        cursadd = "(" + item.Curso + ")";
                    }
                    itec = new ListItem();
                    foreach (var i in item.DiaImpartidos)
                    {
                        horario = horario + i.Dia + "[" + i.Horario + "]";
                    }
                    itec.Text = "(" + item.Materia + ") " + item.Nombre + System.Environment.NewLine + "NRC: " + item.NRC + " Horario: " + horario + cursadd;
                    itec.Value = Utilerias.SerializeObject(item);
                    lstCargal.Items.Add(itec);
                    horario = string.Empty;
                }


                lstCargal.DataBind();

            }
            else
            {

            }
        }
    }
}